import { ILoadMapTypeAll } from '@/common';
import { ManageCommonAPI } from '@/pages/type';
import { getSelectDataMapList, getTenantID } from '@/utils';

/** 材料列表搜索 */
const getMaterialSearchList = (loadInfo: Record<string, any>): ManageCommonAPI.ISearchList => {
  /**资产分类数据字典*/
  // const materialTypeMapList = loadInfo?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`];
  const materialTypeMapList = getSelectDataMapList(loadInfo?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id', true);

  return [
    {
      name: 'assetName',
      placeholder: '材料名称',
      label: '材料名称',
      componentType: 'Input',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'assetClass',
      placeholder: '材料分类',
      label: '材料分类',
      componentType: 'TreeSelect',
      dataSource: materialTypeMapList,
      allowClear: true,
      showSearch: true,
      treeNodeFilterProp: 'name',
      md: 6,
      sm: 24,
      whetherSenior: false,
      fieldNames: {
        label: 'name',
        value: 'id',
        children: 'children',
      },
    },
    {
      name: 'brandType',
      placeholder: '品牌',
      label: '品牌',
      componentType: 'Input',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'paramsInfo',
      placeholder: '规格参数',
      label: '规格参数',
      componentType: 'Input',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: false,
    },
  ];
};

export { getMaterialSearchList };
